package demo1;

import java.util.concurrent.Semaphore;

public class test {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore=new Semaphore(3);//数量
      semaphore.acquire();
        System.out.println("p操作");
      semaphore.acquire();
        System.out.println("p操作");
        semaphore.acquire();
        System.out.println("p操作");
        semaphore.acquire();
        System.out.println("p操作");
    }
}
